import { IFeidaoAiBrowserComponent } from '@dfeidao/atom-web/interfaces';
import get from '@dfeidao/atom-web/local/get';
import nodejs from '@dfeidao/atom-web/msg/nodejs';

import fire from '@dfeidao/atom-web/msg/fire';
import set_node_cls from "@dfeidao/atom-web/ui/set-node-cls";

export default async function a003(fd: IFeidaoAiBrowserComponent) {
	// 删除按钮
	const flag = get(fd, 'flag') as string;
	const no = get(fd, 'no') as string;

	console.log("shifouweik ===", no);
	if (flag === '1') {
		//删除客户信息
		const res = await nodejs<{ code: 0 | 1; result: string; }>('risk_point/zj-000008/s001', {
			filter: {
				risk_po_type_no: no
			}
		});
		if (res.code === 1) {
			alert('删除成功');
			window.location.reload();
		} else {
			alert('删除失败');
		}
	} else if (flag === '2') {
		console.log("撒大声地==》", no);
		fire("zj-000003", "a005", no);

		if (no.length > 0) {
			alert('删除成功');
			// 关闭删除弹框
			const d = fd.data.node.querySelector<HTMLDivElement>('[data-id="delete"]');
			set_node_cls(d, 'display-n', true);
		} else {
			alert('删除失败');
		}
	} else if (flag === '3') {
		//删除客户信息
		const res = await nodejs<{ code: 0 | 1; result: string; }>('risk_point/zj-000008/s002', {
			filter: {
				_id: no
			}
		});
		if (res.code === 1) {
			alert('删除成功');
			window.location.reload();
		} else {
			alert('删除失败');
		}
	} else if (flag === '4') {
		console.log("撒大声地==》", no);
		fire("zj-000004", "a004", no);

		if (no.length > 0) {
			alert('删除成功');
			// 关闭删除弹框
			const d = fd.data.node.querySelector<HTMLDivElement>('[data-id="delete"]');
			set_node_cls(d, 'display-n', true);
		} else {
			alert('删除失败');
		}
	} else if (flag === '5') {
		//删除客户信息
		const res = await nodejs<{ code: 0 | 1; result: string; }>('risk_point/zj-000008/s003', {
			filter: {
				risk_po_name_no: no
			}
		});
		if (res.code === 1) {
			alert('删除成功');
			window.location.reload();
		} else {
			alert('删除失败');
		}
	}
}
